<ul class="breadcrumb">
	<li><a href="/admin">Dashboard</a><span class="divider">&raquo;</span></li>
	<li><a href="/admin/bills">Manager Bill</a><span class="divider">&raquo;</span></li>
	<li class="active">Bill Detail</li>
</ul>

<div class="row-fluid">
	<div class="span12">
		<div class="nonboxy-widget">
			<div class="widget-head">
				<h5><i class="application_detail_co"></i>Bill Detail</h5>
			</div>

			<div class="widget-content">
				<div class="widget-box ">

					<!-- Thong tin khach hang-->
					<div class="title-box"><strong>	Customer Infomation </strong></div>
					<div class="white-radius-box">
						<div class="control-group">
							<label class="control-label">Full name</label>
							<div class="controls"><?php echo $bill[$als]['name_from']?></div>
						</div>

						<div class="control-group">
							<label class="control-label">Phone</label>
							<div class="controls">
								<?php echo $this->Form->input('phone_from', array('div' => false, 'label' => false, 'placeholder' => 'Enter phone', 'class' => 'span4'));?>
							</div>
						</div>

						<div class="control-group">
							<label class="control-label">Address</label>
							<div class="controls">
								<?php echo $this->Form->input('address_to', array('type' => 'text', 'div' => false, 'label' => false, 'placeholder' => 'Enter address', 'class' => 'span6'));?>
							</div>
						</div>
					</div>

							<!-- Thong tin khach hang-->
							<div class="title-box"><strong>	Bill detail </strong></div>
							<div class="white-radius-box">
								<div class="control-group">
									<label class="control-label">Find product</label>
									<div class="controls find">
										<input type="text" id="find" class="span4" data-none=""  placeholder="Enter product" autocomplete="off"/>
										<ul class="unstyled selected"></ul>

										<?php if(!empty($errors['product'])):?>
										<div class="error-message"><?php echo $errors['product']; ?></div>
							            <?php endif;?>
									</div>
								</div>

								<div class="control-group">
									<label class="control-label">Product detail</label>
									<div class="controls">
										<table class="table tbproduct">
											<thead>
											<tr>
												<th>#</th>
												<th>Product name</th>
												<th style="width:100px">Price(VNĐ)</th>
												<th style="width:50px">Amount</th>
												<th style="width:50px"></th>
											</tr>
											</thead>
							              	<tbody>
											<?php if(!empty($details)) foreach($details as $k => $dt) : ?>
												<tr>
													<td class="stt"><?php echo $k + 1?></td>
													<td>
														<?php echo $dt['name']?>
														<input type="hidden" name="data[DetailBill][<?php echo $k; ?>][product_id]" id="DetailBillProductId" value="<?php echo $dt['id']?>">
													</td>
													<td class="pprice"><?php echo number_format( $dt['price'], 0, ',', '.' );?></td>
													<td><input name="data[DetailBill][<?php echo $k; ?>][amount]" value="<?php echo $dt['amount'];?>" class="amount" onblur="bill.setPrice()" type="text" id="DetailBillAmount"></td>
													<td><a href="javascript:;" title="Remove" class="remove" onclick="return bill.removeSelected($(this));" pid="<?php echo $dt['id']?>">Remove</a></td>
												</tr>
											<?php endforeach;?>
						    				</tbody>
							            </table>
									</div>
								</div>
							</div>

							<!-- Thong tin khach hang-->
							<div class="title-box"><strong>	Payment </strong></div>
							<div class="white-radius-box">
								<div class="control-group">
									<label class="control-label"></label>
									<div id="payment" class="controls">
										<div class="fl payment">
											<label>Deposit</label>
											<?php echo $this->Form->input('get_payment', array( 'type' => 'text', 'div' => false, 'label' => false, 'value' => !empty($this->data['Bill']['get_payment']) ? number_format($this->data['Bill']['get_payment'], 0, ',', '.' ) : '0', 'class' => 'span10 number', 'onblur' => 'bill.setPrice()'));?>
										</div>

										<div class="fl payment">
											<label>Sum</label>
											<?php echo $this->Form->input('sum', array('type' => 'text', 'div' => false, 'label' => false, 'readonly' => 'readonly', 'value' => !empty($this->data['Bill']['sum']) ? number_format($this->data['Bill']['sum'], 0, ',', '.' ) : 0,  'class' => 'span10 number'));?>
										</div>

										<div class="fl" style="width:70px">
											<label>Discount</label>
											<?php echo $this->Form->input('discount', array('type' => 'text', 'div' => false, 'label' => false, 'value' => !empty($this->data['Bill']['discount']) ? $this->data['Bill']['discount'] : '0',  'class' => 'span10 number', 'onblur' => 'bill.setPrice()' ));?>
										</div>

										<div class="fl payment">
											<label>Remaining</label>
											<?php echo $this->Form->input('remaining', array('type' => 'text', 'div' => false, 'label' => false, 'value' => !empty($this->data['Bill']['remaining']) ? number_format($this->data['Bill']['remaining'], 0, ',', '.' ) : '0',  'readonly' => 'readonly', 'class' => 'span10 number'));?>
										</div>
									</div>
								</div>
							</div>

						</fieldset>

						<div class="form-actions">
							<button class="btn btn-primary" type="submit">Save</button>
							<a href="/admin/users" class="btn">Cancel</a>
						</div>
					<?php echo $this->Form->end( ); ?>
				</div>
			</div>

		</div>
	</div>
</div>



<!--================================-->
<script type="text/javascript" src="/js/admin/Bill.js"></script>
<script>
function abc(obj)
{
	var a = obj.val();

	a = a.replaceAll([',', '.'], '');

	alert(a);
}

	var select_ctn = '<tr>\
                  <td class="stt"></td>\
                  <td><?php echo $this->Form->input( 'DetailBill.product_id', array( 'type' => 'hidden', 'label' => false, 'div' => false) ) ?> \</td>\
                  <td class="pprice"> </td>\
                  <td>\
                  	<?php echo $this->Form->input( 'DetailBill.amount', array( 'label' => false,  'type' => 'text', 'value' => '1', 'class' => 'amount', 'div' => false, 'onblur' => 'bill.setPrice()'  ) ) ?> \
                  </td>\
                  <td><a href="javascript:;" title="Remove" class="remove"  onclick="return bill.removeSelected($(this));">Remove</a></td>\
                </tr>';


	$(document).ready(function(){
		// Start autocom
		bill.startAuto({
			input: $('#find'),
			selected_ctn: $('.find .selected'),
			item: $(select_ctn),
			index: '<?php echo $index + 1; ?>',
			update: $('.tbproduct tbody')
		});

	});


</script>

